<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>考试</title>
</head>
<style>
    * {
        padding: 0;
        margin: 0;
        list-style: none;
        text-decoration: none;
    }
    
    p span {
        color: rgba(255, 0, 0, 0.5);
    }
</style>

<body>
    <h1>1.请列举css的各种选择器</h1>
    <p>简单选择器: <span>id选择器*/class选择器./通用选择器*</span></p>
    <p>属性选择器: <span>[attr]           
/[attr=val]         全匹配
/[attr~=val]        大约匹配
/[attr|=val]        开始匹配
/[attr^=val]        开始匹配
/[attr$=val]        结束匹配
/[attr*=val]        任意匹配]</span></p>
    <p>伪类与伪元素选择器: <span>链接状态：:hover,:active,:link,:visited:,:focus/
        孩子状态: :first-child ,:nth-child(n) /其他: :before,:after,:first-letter,:first-line</span></p>
    <p>组合选择器: <span>.a .b{}/.a,.b{}/.a>.b{}/.a+.b{}/.a~.b{}</span></p>

    <h1>2 请列出来变量值的变量类型</h1>
    <p>NaN: <span>number</span></p>
    <p>null: <span>空值</span></p>
    <p>undefined: <span>未定义</span></p>
    <p>10: <span>number</span></p>
    <p>"abc": <span>string</span></p>
    <p>infintity: <span>无穷大</span></p>
    <h1>8 简述一下window.onload的意义</h1>
    <p>确保在网页运行完再执行以下js语句</p>
    <h1>10 请列举出从html取得元素的dom函数,如getElementById</h1>
    <p>getElementById</p>
    <p>getElementsByName</p>
    <p>getElementsByTagName</p>
    <p>getElementsByClassName</p>
    <p>querySelector</p>
    <p>querySelectorAll</p>
    <h1>11 请写出innerHTML与innerText的区别</h1>
    <p>innerHTML:从对象的起始位置到终止位置的全部内容,包括Html标签</p>
    <p>innerText:从起始位置到终止位置的内容, 但它去除Html标签</p>

</body>
<script>
    console.log("3 写一段代码,把1到10循环输出");
    for (var i = 1; i < 11; i++) {
        console.log(i);
    }
    console.log("4 写一段代码,判断10是否大于100;如果是,输出大于,如果不是输出小于");
    if (10 > 100) {
        console.log("10大于100");
    } else {
        console.log("10小于100");
    }
    console.log("5 用立即执行函数,去执行这段函数function()");
    (function() {
        console.log("我会立即执行");
    })();
    console.log("6 有一个班举行体育考试,他们的考试成绩用数组表示.现在有一个插班生叫小华,考试75分,并将小华的分数出入到小红跟小花中间")
    var classroom = [{
        name: "小明",
        score: 100
    }, {
        name: "小东",
        score: 90
    }, {
        name: "小红",
        score: 80
    }, {
        name: "小花",
        score: 70
    }, {
        name: "小星",
        score: 60
    }, ]
    classroom.pop();
    classroom.pop();
    var xiaohua = {
        name: "小华",
        score: 75
    }
    classroom.push(xiaohua);
    var xiaofa = {
        name: "小花",
        score: 70
    }
    var xiaoxing = {
        name: "小星",
        score: 60
    }
    classroom.push(xiaofa);
    classroom.push(xiaoxing);
    console.log(classroom);
    console.log("请把上一个数组的分数用正序输出(从小到大排序)");
    var swap = function(oldIndex, newIndex) {
        var temp = classroom[oldIndex];
        classroom[oldIndex] = classroom[newIndex];
        classroom[newIndex] = temp;
    }
    for (var i = 0; i < classroom.length; i++) {
        var min = classroom[i].score;
        var minIndex = i;
        for (var j = i + 1; j < classroom.length; j++) {
            if (classroom[j].score < min) {
                min = classroom[j].score;
                minIndex = j;
            }
        }
        if (minIndex != i) {
            swap(i, minIndex);
        }
    }
    console.log(classroom);
    console.log("9 请写一个函数判断一下www.taobao.com中间是否是'taobao'");

    var tb = "www.taobao.com";
    // console.log(tb.slice(4, 10));
    if (tb.slice(4, 10) == "taobao") {
        console.log("www.taobao.com中间是'taobao'")
    }
    var i = 0;
    var timer = setInterval(function() {
        if (i < 10) {
            i++;
            console.log(i);
        } else {
            clearInterval(timer);
        }
    }, 1000);
</script>

</html>